<template>
  <div id="home">
    <div class="left" ref="left">
      <div class="logo">
        <div>222222222222</div>
      </div>
      <div>
        <el-menu
          default-active="2"
          class="el-menu-vertical-demo"
          :collapse="isCollapse"
        >
          <el-submenu index="1">
            <template slot="title">
              <i class="el-icon-s-fold"></i>
              <span>导航一{{ isCollapse }}</span>
            </template>
            <el-menu-item-group>
              <template slot="title">分组一</template>
              <el-menu-item index="1-1">选项1</el-menu-item>
              <el-menu-item index="1-2">选项2</el-menu-item>
            </el-menu-item-group>
            <el-menu-item-group title="分组2">
              <el-menu-item index="1-3">选项3</el-menu-item>
            </el-menu-item-group>
            <el-submenu index="1-4">
              <template slot="title">选项4</template>
              <el-menu-item index="1-4-1">选项1</el-menu-item>
            </el-submenu>
          </el-submenu>
          <el-menu-item index="2">
            <i class="el-icon-menu"></i>
            <span slot="title">导航二</span>
          </el-menu-item>
          <el-menu-item index="3" disabled>
            <i class="el-icon-document"></i>
            <span slot="title">导航三</span>
          </el-menu-item>
          <el-menu-item index="4">
            <i class="el-icon-setting"></i>
            <span slot="title">导航四</span>
          </el-menu-item>
        </el-menu>
      </div>
    </div>
    <div class="main_body" ref="body">
      <div class="header">
        <div class="navbar">
          <div style="padding: 0 15px" @click="indentation">
            <i
              style="font-size: 24px"
              :class="!isCollapse ? 'el-icon-s-fold' : 'el-icon-s-unfold'"
            ></i>
          </div>
          <el-breadcrumb separator="/">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item><a href="voide">活动管理</a></el-breadcrumb-item>
            <el-breadcrumb-item>活动列表</el-breadcrumb-item>
            <el-breadcrumb-item>活动详情</el-breadcrumb-item>
          </el-breadcrumb>
        </div>
        <div class="tages">
          <el-tag
            :key="tag"
            v-for="tag in dynamicTags"
            closable
            :disable-transitions="false"
            @close="handleClose(tag)"
          >
            {{ tag }}
          </el-tag>
          <el-input
            class="input-new-tag"
            v-if="inputVisible"
            v-model="inputValue"
            ref="saveTagInput"
            size="small"
            @keyup.enter.native="handleInputConfirm"
            @blur="handleInputConfirm"
          >
          </el-input>
          <el-button
            v-else
            class="button-new-tag"
            size="small"
            @click="showInput"
            >+ New Tag</el-button
          >
        </div>
      </div>
      <div class="main">
        <router-view></router-view>
      </div>
    </div>
  </div>
</template>
<script>
import Tag from "../../components/tag.vue";
export default {
  comments: {
    Tag,
  },
  name: "home",
  data() {
    return {
      dynamicTags: ["标签一", "标签二", "标签三"],
      inputVisible: false,
      inputValue: "",
      isCollapse: false,
    };
  },
  methods: {
    handleClose(tag) {
      this.dynamicTags.splice(this.dynamicTags.indexOf(tag), 1);
    },

    showInput() {
      this.inputVisible = true;
      this.$nextTick(() => {
        this.$refs.saveTagInput.$refs.input.focus();
        this.$router.push({
          path:`/trends:1`
        })
      });
    },

    handleInputConfirm() {
      let inputValue = this.inputValue;
      if (inputValue) {
        this.dynamicTags.push(inputValue);
      }
      this.inputVisible = false;
      this.inputValue = "";
    },
    indentation() {
      const body = this.$refs.body;
      const dom = this.$refs.left;
      if (!this.isCollapse) {
        this.isCollapse = true;
        dom.style.width = "54px";
        body.style.marginLeft = "54px";
      } else {
        this.isCollapse = false;
        dom.style.width = "200px";
        body.style.marginLeft = "200px";
      }
    },
  },
};
</script>
<style>
.el-breadcrumb {
  font-size: 14px;
  line-height: 1;
  line-height: 50px !important;
}
.el-tag + .el-tag {
  margin-left: 10px;
}
.button-new-tag {
  margin-left: 10px;
  height: 32px;
  line-height: 30px;
  padding-top: 0;
  padding-bottom: 0;
}
.input-new-tag {
  width: 90px;
  margin-left: 10px;
  vertical-align: bottom;
}
.header {
  background: #cdcdcd;
}
.el-menu {
  border-right: none !important;
}
/* .el-submenu__title {
  padding-left: 15px !important;
  padding: 0 15px !important;
} */

.el-menu--collapse {
  width: 100% !important;
}
.el-icon-location {
  width: 10px !important;
  padding-right: 10px !important;
}
.el-menu-item [class^="el-icon-"] {
  width: 10px !important;
  padding-right: 10px !important;
}
/* .el-tooltip {
  padding: 0px 15px !important;
} */
.left {
  transition: width 0.28s;
  width: 200px;
  /* background-color: #304156; */
  background-color: rgb(255, 255, 255);
  height: 100%;
  position: fixed;
  font-size: 0;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1001;
  overflow: hidden;
  box-shadow: 2px 0 6px rgba(0, 21, 41, 0.35);
  cursor: pointer;
}
i {
  cursor: pointer;
}
.main_body {
  height: 100%;
  transition: margin-left 0.28s;
  margin-left: 200px;
  position: relative;
}
.navbar {
  height: 50px;
  overflow: hidden;
  position: relative;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
  display: flex;
  align-items: center;
}
.tages {
  height: 34px;
  width: 100%;
  background: #fff;
  border-bottom: 1px solid #d8dce5;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.12), 0 0 3px 0 rgba(0, 0, 0, 0.04);
}
.main {
  min-height: calc(100vh - 84px);
  width: 100%;
  position: relative;
  overflow: hidden;
}
.logo {
  position: relative;
  width: 100%;
  height: 50px;
  line-height: 50px;
  /* background: #2b2f3a; */
  background-color: rgb(255, 255, 255);
  color: rgb(0, 21, 41) !important;
  font-size: 16px;
  text-align: center;
  overflow: hidden;
}
</style>